nums = [-1,0,1,2,-1,-4]
var threeSum = function(nums) {
    const len=nums.length
    const res=[]
    const Map={}
    for(let i=0;i<len;i++)
    {
        for(let j=i+1;j<len;j++)
        {
            for(let k=j+1;k<len;k++)
            {
                if(nums[i]+nums[j]+nums[k]===0)
                {
                    const triplet=[nums[i],nums[j],nums[k]]
                    triplet.sort((a,b)=>(a-b))
                    const key=triplet.join(',')
                    if(!Map[key])
                    {
                        Map[key]=true
                        res.push(triplet)
                    }

                }
            }
        }
    }
    return res;


}(nums);
console.log(threeSum)